<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Validation {

	// is_numeric

	/**
	 * @author DatDM
	 * @param string $val
	 */
	public function isRequired($val) {
		$val = trim($val);
		if(strlen($val) == 0) {
			return FALSE;
		}
		return TRUE;
	}

	/**
	 * @author DatDM
	 * @param string $val
	 */
	public function isEmail($val) {
		// Set up regular expression strings to evaluate the value of email variable against
		$regex = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/';
		// Run the preg_match() function on regex against the email address
		if (preg_match($regex, $email)) {
			return TRUE;
		}
		return FALSE;
	}

	/**
	 * @author DatDM
	 * @param string $val
	 */
	public function isPasswordComplixity($val) {
		$val = trim($val);
		if(strlen($val) < 5 || strlen($val) > 16) {
			return false;
		}
		if( ! preg_match('[a-z]+', $val)) {
			return false;
		}
		if( ! preg_match('[A-Z]+', $val)) {
			return false;
		}
		if( ! preg_match('[0-9]+', $val)) {
			return false;
		}
		return true;
	}



} // end class Validation
